import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/openeye/widget/app_bar.dart';
import 'package:flutter_app/stateLearn/click_txt.dart';
import 'package:get/get.dart';

class PageTwo extends StatefulWidget {
  const PageTwo({Key? key}) : super(key: key);

  @override
  _PageTwoState createState() => _PageTwoState();
}

class _PageTwoState extends State<PageTwo> {
  var _radioValue = "0";
  double _sliderValue = 0;

  @override
  Widget build(BuildContext context) {
    return materialPage(appBar: appBar("第二页"), page: createSnackBar(context));
  }
  createSnackBar(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      child: ClickTxt(info: "测试底部弹窗",onPressed: (){
        Get.snackbar("弹窗", "弹窗测试",snackPosition:SnackPosition.BOTTOM,);

      },),
    );
  }
  createRadioPage() {
    return Row(
      children: <Widget>[
        Flexible(
          child: RadioListTile(
            title: Text("历史"),
            value: "历史",
            onChanged: (String? value) {
              setState(() {
                _radioValue = value ?? "0";
              });
            },
            groupValue: _radioValue,
          ),
        ),
        Flexible(
          child: RadioListTile(
            title: Text("数学"),
            value: "数学",
            onChanged: (String? value) {
              setState(() {
                _radioValue = value ?? "0";
              });
            },
            groupValue: _radioValue,
          ),
        ),
      ],
    );
  }

  createSliderPage() {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(_sliderValue.toString()),
        Slider(
            value: _sliderValue,
            min: 0,
            max: 100,
            label: _sliderValue.toString(),
            onChanged: (value) {
              setState(() {
                _sliderValue = value;
              });
            })
      ],
    );
  }

  var _switchValue = false;

  createSwitchPage() {
    return SwitchListTile(
      title: Text("开启蓝牙"),
      onChanged: (bool value) {
        setState(() {
          _switchValue = value;
        });
      },
      value: _switchValue,
    );
  }

  createImagePage() {
    // return InkWell(child: Image.asset("assets/images/ic_discovery_normal.png",width: 100,height: 200,),onTap: (){
    //   getTemporaryDirectory().then((value){
    //     print(value.path);
    //   });
    // },);
    return Directionality(
      textDirection: TextDirection.rtl,
      child: Image.network(
        "http://pic1.win4000.com/pic/c/cf/cdc983699c.jpg",
        matchTextDirection: true,
      ),
    );
  }

  createWrapImagePage() {
    var color = Colors.red.withAlpha(63);
    var path = "http://pic1.win4000.com/pic/c/cf/cdc983699c.jpg";
    var width = double.parse("150");
    var height = double.parse("150");
    List<Map> list = [
      {
        "color": color,
        "mod": BlendMode.clear,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.color,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.colorBurn,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.colorDodge,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.darken,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.difference,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.dst,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.dstATop,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.dstIn,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.dstOut,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.dstOver,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.exclusion,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.hardLight,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.hue,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.lighten,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.modulate,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.multiply,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.overlay,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.plus,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.saturation,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.screen,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.softLight,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.src,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.srcATop,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.srcIn,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.srcOver,
        "path": path,
        "width": width,
        "height": height,
      },
      {
        "color": color,
        "mod": BlendMode.xor,
        "path": path,
        "width": width,
        "height": height,
      },
    ];

    return Wrap(
        runSpacing: 18,
        spacing: 18,
        children: List.generate(list.length, (index) {
          return Image.network(
            list[index]['path'],
            width: list[index]['width'],
            height: list[index]['height'],
            color: list[index]['color'],
            colorBlendMode: list[index]['mod'],
            filterQuality: FilterQuality.high,
          );
        }));
  }

  createIconPage() {
    return Container(
        alignment: Alignment.center,
        child: Icon(
          const IconData(0xe686, fontFamily: "appIconFonts"),
          size: 80,
          color: Colors.red.withAlpha(70),
        ));
  }


}
